<?php 
namespace app\index\Controller;
use think\Controller;
use think\Db;//导入数据库类 (DB类)


class Section  extends Controller
{
    public function index()

    {
    	//当前位置板块
    	
    	$nav=db('session')->where('id',input('id'))->find();
        // var_dump($nav);exit;
    	if ($nav>0) {
            $this->assign('nav',$nav);
        }else{
             return view('404/404');
        }
    	// dump($nav);exit;

        //板块遍历
          $data=db('session')->field(['name','id'])->select();
       
    	// dump($data);
    	$this->assign('data',$data);

    	//热帖排行
    	 $res=db('article')->field(['title','id'])->where('ses_id',input('id'))->select();
    	 // dump($res);
    	 $this->assign('res',$res);


    	 //板块帖子列表
    	$resu=db('article')->where('ses_id',input('id'))->paginate(5);
    	// dump($resu);exit;
        // 获取分页显示
        $page = $resu->render();
        // 模板变量赋值
        $this->assign('page', $page);
    	$this->assign('resu',$resu);

        // 版头明星
        $star=Db::field('user.icon,star.name')
        ->table('bbs_user user,bbs_star star')
        ->where('user.id=star.uid')
        ->select();

        $this->assign('star',$star);
    	return view('Section/section');


    }







    public function post()
    {
          if (empty(input('session.user.id'))) {
        $this->error('登陆后才能执行操作哦','/index/User/login');
      }
        $nav=db('session')->where('id',input('sid'))->find();
        $this->assign('nav',$nav);
        return view('Section/post');
    }

     
}

